package com.ruoyi.web.controller.pwk;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pwk.domain.BusPwkRhoutfall;
import com.ruoyi.pwk.service.IBusPwkRhoutfallService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入河排污口Controller
 * 
 * @author ruoyi
 * @date 2025-07-27
 */
@RestController
@RequestMapping("/pwk/rhoutfall")
public class BusPwkRhoutfallController extends BaseController
{
    @Autowired
    private IBusPwkRhoutfallService busPwkRhoutfallService;

    /**
     * 查询入河排污口列表
     */
    //@PreAuthorize("@ss.hasPermi('pwk:rhoutfall:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusPwkRhoutfall busPwkRhoutfall)
    {
        startPage();
        List<BusPwkRhoutfall> list = busPwkRhoutfallService.selectBusPwkRhoutfallList(busPwkRhoutfall);
        return getDataTable(list);
    }

    /**
     * 排污口列表
     */
    //@PreAuthorize("@ss.hasPermi('pwk:rhoutfall:listall')")
    @GetMapping("/listall")
    public AjaxResult listall(BusPwkRhoutfall busPwkRhoutfall)
    {
        List<BusPwkRhoutfall> list = busPwkRhoutfallService.selectBusPwkRhoutfallList(busPwkRhoutfall);
        return AjaxResult.success(list);
    }

    /**
     * 导出入河排污口列表
     */
    //@PreAuthorize("@ss.hasPermi('pwk:rhoutfall:export')")
    //@Log(title = "入河排污口", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusPwkRhoutfall busPwkRhoutfall)
    {
        List<BusPwkRhoutfall> list = busPwkRhoutfallService.selectBusPwkRhoutfallList(busPwkRhoutfall);
        ExcelUtil<BusPwkRhoutfall> util = new ExcelUtil<BusPwkRhoutfall>(BusPwkRhoutfall.class);
        util.exportExcel(response, list, "入河排污口数据");
    }

    /**
     * 获取入河排污口详细信息
     */
    //@PreAuthorize("@ss.hasPermi('pwk:rhoutfall:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(busPwkRhoutfallService.selectBusPwkRhoutfallById(id));
    }
    /**
     * 新增入河排污口
     */
    //@PreAuthorize("@ss.hasPermi('pwk:rhoutfall:add')")
    //@Log(title = "入河排污口", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusPwkRhoutfall busPwkRhoutfall)
    {
        return toAjax(busPwkRhoutfallService.insertBusPwkRhoutfall(busPwkRhoutfall));
    }

    /**
     * 修改入河排污口
     */
    //@PreAuthorize("@ss.hasPermi('pwk:rhoutfall:edit')")
    //@Log(title = "入河排污口", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusPwkRhoutfall busPwkRhoutfall)
    {
        return toAjax(busPwkRhoutfallService.updateBusPwkRhoutfall(busPwkRhoutfall));
    }

    /**
     * 关联分析污染源数据
     * @return
     */
    @GetMapping("/analyzepollutionsource")
    public AjaxResult analyzepollutionsource(String startTime,String endTime,String pollutantcode,String outfallid){

        return AjaxResult.success(busPwkRhoutfallService.analyzepollutionsource(startTime,endTime,pollutantcode,outfallid));
    }

    /**
     * 关联分析污染源数据
     * @return
     */
    @GetMapping("/analyzesegment")
    public AjaxResult analyzesegment(String startTime,String endTime,String pollutantcode,String outfallid){

        return AjaxResult.success(busPwkRhoutfallService.analyzesegment(startTime,endTime,pollutantcode,outfallid));
    }
    /**
     * 删除入河排污口
     */
    //@PreAuthorize("@ss.hasPermi('pwk:rhoutfall:remove')")
    //@Log(title = "入河排污口", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busPwkRhoutfallService.deleteBusPwkRhoutfallByIds(ids));
    }
}
